package com.lihonghao.gateway.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class BeanDefinition<T> {
    // 全局唯一的Bean Name:
    String name;

    // Bean的声明类型:
    Class<?> beanClass;

    // Bean的实例:
    Object instance = null;

    // 构造方法/null:
    Constructor<?> constructor;

    // 工厂方法名称/null:
    String factoryName;

    // 工厂方法/null:
    Method[] factoryMethods;

    // Bean的顺序:
    int order;

    // 是否标识@Primary:
    boolean primary;

    // init/destroy方法名称:
    String initMethodName;
    String destroyMethodName;

    // init/destroy方法:
    Method initMethod;
    Method destroyMethod;

    public BeanDefinition(Class<?> clazz, String className, Object obj, Method[] methods) {
        this.beanClass = clazz;
        this.instance = obj;
        this.factoryMethods = methods;
    }
}
